<template>
  <div>
    <p>工厂考察评估</p>
    <el-button type="primary" @click="check()" style="margin-bottom:20px">审核</el-button>
    <!-- <el-button type="primary" @click="back()" style="margin-bottom:20px">返回</el-button> -->
    <el-form :model="dlvApplyData">
      <el-row>
        <el-col :span="4">
          <div class="grid-content bg-purple">采购组织</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple-light">{{dlvApplyData.purOrgName}}</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">采购组</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple-light">{{dlvApplyData.purGroupName}}</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">品类</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple-light">{{dlvApplyData.categoryName}}</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="4">
          <div class="grid-content bg-purple">申请主题</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple-light">{{dlvApplyData.title}}</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">申请原因</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple-light">{{dlvApplyData.applyReason}}</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">现有供应商</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple-light">{{dlvApplyData.vendors}}</div>
        </el-col>
      </el-row>
    </el-form>
    <p>指定开发供应商清单</p>
    <el-table :data="dlvApplyItemData" style="width: 100%" max-height="250" :default-sort="{prop: 'vendorCode', order: 'descending'}">
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column prop="id" v-if='isShow'></el-table-column>
      <el-table-column prop="operation" align="center" width="100" label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="turnToQualified(scope.row)">转合格供应商</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="vendorCode" align="left" label="供应商编码" width="300"></el-table-column>
      <el-table-column prop="vendorName" align="left" label="供应商名称" width="200"></el-table-column>
      <el-table-column prop="vendorLevel" align="left" label="供应商等级" width="150"></el-table-column>
      <el-table-column prop="applyType" align="left" label="引入类型" width="150"></el-table-column>
      <el-table-column prop="dlvItemFlow" align="left" label="开发流程" width="200"></el-table-column>
      <el-table-column prop="supplyArea" align="left" label="供货区域" width="200"></el-table-column>
      <el-table-column prop="remarks" align="left" label="备注" width="200"></el-table-column>
    </el-table>
    <el-dialog title="审核" :visible.sync="dialogFormVisible">
      <el-form :model="checkForm">
        <el-form-item label="结论" :label-width="formLabelWidth">
            <template>
              <el-radio-group v-model="checkForm.dg_checkStatus">
                <el-radio-button v-for="checkOption in checkOptions" :label="checkOption[0]" :key="checkOption[0]">{{checkOption[1]}}</el-radio-button>
              </el-radio-group>
            </template>
          </el-form-item>
        <el-form-item label="审核意见" :label-width="formLabelWidth">
          <el-input v-model="checkForm.dg_checkContent" auto-complete="off"></el-input>
        </el-form-item>
        <!-- <el-form-item label="附件" :label-width="formLabelWidth">
          <el-input v-model="checkForm.dg_checkAttachment" auto-complete="off"></el-input>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitCheck(checkForm)">提交</el-button>
        <el-button @click="dialogFormVisible = false">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import qs from 'qs';
  export default {
    data() {
      return {
        // 新增、修改专家的标签默认值
        checkOptions: [['1','通过'], ['-1','驳回']],
        // 默认隐藏弹出框
        dialogFormVisible: false,
        dlvApplyId: this.$route.query.dlvApplyId,
        // 是否显示隐藏列
        isShow: false,
        // 对话框列宽
        formLabelWidth: '120px',
        dlvApplyItemData: [],
        dlvApplyData:{},
        checkForm:{
          dg_checkStatus:1,
        }
      };
    },
    mounted() {
      this.getDlvApply();
      this.getDlvApplyItem();
    },
    methods: {
      // 查询供应商开发申请
      getDlvApply() {
         this.securityPost(this.lib.config.host.vendorMgt + "/vendormgt/dlv/dlvApply/findDlvApply/" + this.dlvApplyId)
          .then((response) => {
            console.log(response);
            this.dlvApplyData = response;
          })
          .catch((error) => {
            console.log(error);
          });
      },
      // 查询供应商开发申请明细
      getDlvApplyItem() {
         this.securityPost(this.lib.config.host.vendorMgt + "/vendormgt/dlv/dlvApply/findDlvApplyItemList/" + this.dlvApplyId)
          .then((response) => {
            console.log(response);
            this.dlvApplyItemData = response;
          })
          .catch((error) => {
            console.log(error);
          });
      },
      check() {
        //修改弹框
        this.dialogFormVisible = true
      },
      // 提交审核
      submitCheck(checkForm) {
        debugger;
        this.dialogFormVisible=false;
         this.securityPost(this.lib.config.host.vendorMgt + "/vendormgt/dlv/dlvApply/check/" +  this.dlvApplyId, qs.stringify(checkForm))
          .then((response)=>{
            this.mounted();
          })
          .catch((error)=>{
            console.log(error);
          });
      },
       // 转合格供应商
      turnToQualified(row) {
         let id = row.id;
         window.open('/TurnToQualifiedVendor?dlvApplyItemId='+ id)
        //  let id = row.id;
        //  this.$router.push('/Index/VendorDlv/SaveOrUpdateDlvApply?dlvApplyId='+ id);
      },
    }
  }

</script>
<style scoped>
  .el-col {
    border-radius: 0px;
  }
  .bg-purple {
    border: 1px solid #ccc;
    background: #eee;
  }

  .bg-purple-light {
    border: 1px solid #ccc;
    background: #fff;
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  .grid-content{
    border-radius: 0;
  }
</style>
